/*印章的大小*/
var yz_size=0;
var str="";
var can=null;
var cxt=null;
/*线条的宽度*/
var linewidth=0;
/*计算大小*/
function jisuan1(string,daxiao){
    str=string;
    yz_size=daxiao;
    /*canvas是html5中的绘图标签*/
    var stri="<div id='yinzhang'><img id='yz' width='"+yz_size+"px' height='"+yz_size+"px'></img><canvas id='canvas' width='"+yz_size*10+"px' height='"+yz_size*10+"px'></canvas></div>";
    document.write(stri);
    /*得到Canvas对象的绘图id的标签*/
    can=document.getElementById("canvas");
    yz_size=daxiao*10;
    /*调用Canvas对象的getContext()方法，得到一个CanvasRenderingContext2D对象；*/
    cxt=can.getContext("2d");
    /*清除矩形区域：context.clearRect(x,y,width,height)。*/
    cxt.clearRect(0,0,yz_size,yz_size);
    var a=yz_size/2;
    var size=a/2.5;
    var str_w=0;
    var str_h=size;
    /*线条的粗细*/
    lineWidth=a/25;
    circle("#f00",a,a,a*0.9);
    text(a/1.8,"★",a-(a/1.8/2),a+(a/1.8/3),a/1.8);
    var len=str.length;
    var x1=0;
    var x2=0;
    var b=0;
    var c=0;
    var d=0;
    var e=0;
    var c1=0;
    var d1=0;
    /*计算绘制五角星个尖尖的坐标*/
    for(var i=0;i<len;i++){
        x1=i*300/len+30;
        x2=(i+1)*300/len+30;
        x=(x1+x2)/2;
        str_w=Math.PI*a/len;
        str_w=str_w<str_h?str_w:str_h;
        c1=(a-(a+str_h)/2*sin(x));
        d1=(a+(a+str_h)/2*cos(x));
        /*atan()函数可返回数字的反正切值*/
        b=atan(c1/d1);
        /*sqrt()函数是非负实数的平方根*/
        e=Math.sqrt(c1*c1+d1*d1);
        c=e*cos(90-x-b);
        d=e*sin(90-x-b);
        /*rotate()计算旋转度数*/
        cxt.rotate(-(180-x)*Math.PI/180);
        text(str_h,""+str.substr(i,1),(-c)-(str_w/2),(-d)+(str_h/2),str_w);
        cxt.rotate((180-x)*Math.PI/180);
    }
    /*toDataURL转格式类型*/
    var yz=can.toDataURL();
    can.style.visibility="hidden";
    document.getElementById("yz").src=""+yz;
    document.getElementById("yinzhang").style.overflow="hidden";
    document.getElementById("yinzhang").style.width=daxiao+"px";
    document.getElementById("yinzhang").style.height=daxiao+"px";
}
function text(size,str,x,y,width){
    cxt.beginPath();
    cxt.fillStyle="#F00";;
    cxt.font="bold "+size+"px Arial";
    cxt.fillText(str,x,y,width);
    cxt.fill();
    cxt.closePath();
}
function circle(color,x1,y1,z1){
    cxt.beginPath();
    /*绘图样式*/
    cxt.strokeStyle=color;
    cxt.lineWidth=lineWidth;
    cxt.arc(x1,y1,z1,0,2*Math.PI,false);
    /*绘图*/
    cxt.stroke();
    cxt.closePath();
}
/*正弦*/
function sin(x){
    return Math.sin(Math.PI*x/180);
}
/*余弦*/
function cos(x){
    return Math.cos(Math.PI*x/180);
}
/*反切*/
function atan(x){
    return Math.atan(x)*180/Math.PI;
}